const sql = require('../mysql/mysql.js');

var addAdmin = 'INSERT INTO sys_user(username,pwd,createtime,usertype) VALUES(?,?,?,?)'
var updataAdmin = 'UPDATE sys_user SET pwd = ? , usertype = ? WHERE username = ?';
// var updataAdmin = 'SELECT * FROM sys_user WHERE id = ?';
var params = ['qwe123', 2,'admin']


let testMySql = (router) => {
	router.post('/test/mysql', (ctx, next)=>{
		sql.query(addAdmin, params)
		.then(res => {
			console.log('resresrese', res);
		}, err =>{
			console.log('err', err);
		})
		ctx.body = '测试MySQL'
	})
	router.post('/test/mysqlupdata', (ctx, next)=>{
		sql.query(updataAdmin, params)
		.then(res => {
			console.log(res, 'res');
		}, err =>{
			console.log('err', err);
		})
		ctx.body = '测试MySQL'
	})
}

module.exports = testMySql